#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

int main() {
    // 使用vector
    std::vector<int> vec;
    vec.push_back(10);
    vec.push_back(20);
    vec.push_back(30);

    std::cout << "Vector elements: ";
    for (int i = 0; i < vec.size(); i++) {
        std::cout << vec[i] << " ";
    }
    std::cout << std::endl;

    // 使用pop_back
    vec.pop_back();

    // 使用erase
    vec.erase(vec.begin() + 1);

    // 使用clear
    vec.clear();

    // 使用set
    std::set<int> s;
    s.insert(10);
    s.insert(20);
    s.insert(30);

    std::cout << "Set elements: ";
    for (auto it = s.begin(); it != s.end(); it++) {
        std::cout << *it << " ";
    }
    std::cout << std::endl;

    // 使用erase
    s.erase(20);

    // 使用find
    auto it = s.find(30);
    if (it != s.end()) {
        std::cout << "Found 30 in set" << std::endl;
    }

    // 使用map
    std::map<int, std::string> m;
    m[1] = "One";
    m[2] = "Two";
    m[3] = "Three";

    std::cout << "Map elements: ";
    for (auto it = m.begin(); it != m.end(); it++) {
        std::cout << it->first << ": " << it->second << ", ";
    }
    std::cout << std::endl;

    // 使用erase
    m.erase(2);

    // 使用find
    auto it2 = m.find(3);
    if (it2 != m.end()) {
        std::cout << "Found 3 in map" << std::endl;
    }

    // 使用queue
    std::queue<int> q;
    q.push(10);
    q.push(20);
    q.push(30);

    std::cout << "Queue elements: ";
    while (!q.empty()) {
        std::cout << q.front() << " ";
        q.pop();
    }
    std::cout << std::endl;

    // 使用priority_queue
    std::priority_queue<int> pq;
    pq.push(10);
    pq.push(20);
    pq.push(30);

    std::cout << "Priority Queue elements: ";
    while (!pq.empty()) {
        std::cout << pq.top() << " ";
        pq.pop();
    }
    std::cout << std::endl;

    // 使用stack
    std::stack<int> st;
    st.push(10);
    st.push(20);
    st.push(30);

    std::cout << "Stack elements: ";
    while (!st.empty()) {
        std::cout << st.top() << " ";
        st.pop();
    }
    std::cout << std::endl;

    // 使用pair
    std::pair<int, std::string> p = std::make_pair(1, "One");
    std::cout << "Pair: " << p.first << ": " << p.second << std::endl;

    // 使用algorithm头文件下的常用函数
    std::vector<int> vec2 = {10, 20, 30, 40, 50};
    std::reverse(vec2.begin(), vec2.end());

    std::cout << "Reversed vector elements: ";
    for (int i = 0; i < vec2.size(); i++) {
        std::cout << vec2[i] << " ";
    }
    std::cout << std::endl;

    return 0;
}